cmake_minimum_required(VERSION 2.6)
project(nexrad)

set (nexrad_VERSION_MAJOR 0)
set (nexrad_VERSION_MINOR 1)

cmake_policy(SET CMP0015 OLD)
include_directories( . )

include(GNUInstallDirs)

add_executable(nexrad
main.c nexrad.c utm.c grid.c png.c)

if(EXISTS /usr/bin/curl)
message("curl exists")
else(EXISTS /usr/bin/curl)
message(FATAL_ERROR "Nexrad relies on the application curl.")
endif(EXISTS /usr/bin/curl)



find_package(PNG REQUIRED)
if(PNG_FOUND)
target_link_libraries(nexrad png)
endif(PNG_FOUND)


message("Archive Dir:" ${CMAKE_INSTALL_FULL_BINDIR} "Include:" ${CMAKE_INSTALL_FULL_INCLUDEDIR})

#install(DIRECTORY
#docs
#DESTINATION ${CMAKE_INTALL_FULL_DOCSDIR}/kuato)


target_link_libraries(nexrad pthread)

add_definitions( -Wall )

install(TARGETS nexrad DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})

# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(docs ALL
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.config
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)

#TODO: Add package build